package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try (Connection connection = DBUti1.getconnection();){
            Statement st = connection.createStatement();
            String s ="SELECT id,name,salary,title " +
                      "FROM teacher";
            ResultSet rs = st.executeQuery(s);
            while (rs.next()){
//                int id = rs.getInt("id");
//                String name = rs.getString("name");
//                String salary = rs.getString("salary");
//                String title = rs.getString("title");
                int id = rs.getInt("1");
                String name = rs.getString("2");
                String salary = rs.getString("3");
                String title = rs.getString("4");
                System.out.println(id+","+name+","+salary+","+title);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
